home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / Src / Ch5 / Printers.frm (.txt) < prev    next >
Visual Basic Form  |  1999-04-05  |  2KB  |  75 lines

  1. VERSION 5.00
  2. Begin VB.Form frmPrinters 
  3.    Caption         =   "Printers"
  4.    ClientHeight    =   4140
  5.    ClientLeft      =   2325
  6.    ClientTop       =   1260
  7.    ClientWidth     =   4485
  8.    LinkTopic       =   "Form1"
  9.    PaletteMode     =   1  'UseZOrder
  10.    ScaleHeight     =   4140
  11.    ScaleWidth      =   4485
  12.    Begin VB.TextBox txtPrinters 
  13.       BeginProperty Font 
  14.          Name            =   "Courier New"
  15.          Size            =   8.25
  16.          Charset         =   0
  17.          Weight          =   400
  18.          Underline       =   0   'False
  19.          Italic          =   0   'False
  20.          Strikethrough   =   0   'False
  21.       EndProperty
  22.       Height          =   2415
  23.       Left            =   120
  24.       Locked          =   -1  'True
  25.       MultiLine       =   -1  'True
  26.       ScrollBars      =   3  'Both
  27.       TabIndex        =   0
  28.       Top             =   120
  29.       Width           =   2775
  30.    End
  31. Attribute VB_Name = "frmPrinters"
  32. Attribute VB_GlobalNameSpace = False
  33. Attribute VB_Creatable = False
  34. Attribute VB_PredeclaredId = True
  35. Attribute VB_Exposed = False
  36. Option Explicit
  37. ' Load the list of printers.
  38. Private Sub Form_Load()
  39. Dim pr As Printer
  40. Dim txt As String
  41. Dim device_name As String
  42. Dim device_fmt As String
  43. Dim device_len As Integer
  44. Dim port_name As String
  45. Dim port_fmt As String
  46. Dim port_len As Integer
  47. Dim driver_name As String
  48.     ' See how long each field is.
  49.     For Each pr In Printers
  50.         If device_len < Len(pr.DeviceName) Then device_len = Len(pr.DeviceName)
  51.         If port_len < Len(pr.Port) Then port_len = Len(pr.Port)
  52.     Next pr
  53.     ' Build some formatting strings.
  54.     device_fmt = Left$("!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", device_len + 3)
  55.     port_fmt = Left$("!@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@", port_len + 3)
  56.     ' Build the output string.
  57.     txt = Format$("Device", device_fmt) & _
  58.           Format$("Port", port_fmt) & _
  59.           "Driver" & vbCrLf
  60.     txt = txt & _
  61.           Format$("------", device_fmt) & _
  62.           Format$("----", port_fmt) & _
  63.           "------" & vbCrLf
  64.     For Each pr In Printers
  65.         txt = txt & _
  66.               Format$(pr.DeviceName, device_fmt) & _
  67.               Format$(pr.Port, port_fmt) & _
  68.               pr.DriverName & vbCrLf
  69.     Next pr
  70.     txtPrinters.Text = txt
  71. End Sub
  72. Private Sub Form_Resize()
  73.     txtPrinters.Move 0, 0, ScaleWidth, ScaleHeight
  74. End Sub
  75.